/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ecom.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author simon
 */
@Entity
@Table(name = "adress")
@NamedQueries({
    @NamedQuery(name = "Adress.findAll", query = "SELECT a FROM Adress a"),
    @NamedQuery(name = "Adress.findByIdAdress", query = "SELECT a FROM Adress a WHERE a.idAdress = :idAdress"),
    @NamedQuery(name = "Adress.findByZipcode", query = "SELECT a FROM Adress a WHERE a.zipcode = :zipcode"),
    @NamedQuery(name = "Adress.findByStreet", query = "SELECT a FROM Adress a WHERE a.street = :street"),
    @NamedQuery(name = "Adress.findByCity", query = "SELECT a FROM Adress a WHERE a.city = :city")})
public class Adress implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "idAdress")
    private Integer idAdress;
    @Column(name = "zipcode")
    private String zipcode;
    @Column(name = "street")
    private String street;
    @Column(name = "city")
    private String city;
    @JoinColumn(name = "country_id", referencedColumnName = "idcountry")
    @ManyToOne(optional = false)
    private Country country;


    public Adress() {
    }

    public Adress(Integer idAdress) {
        this.idAdress = idAdress;
    }

    public Integer getIdAdress() {
        return idAdress;
    }

    public void setIdAdress(Integer idAdress) {
        this.idAdress = idAdress;
    }

    public String getZipcode() {
        return zipcode;
    }

    public void setZipcode(String zipcode) {
        this.zipcode = zipcode;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public Country getCountry() {
        return country;
    }

    public void setCountry(Country country) {
        this.country = country;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAdress != null ? idAdress.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Adress)) {
            return false;
        }
        Adress other = (Adress) object;
        if ((this.idAdress == null && other.idAdress != null) || (this.idAdress != null && !this.idAdress.equals(other.idAdress))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ecom.dao.hbm.Adress[idAdress=" + idAdress + ""
                + "  zipcode=" + zipcode + ""
                + "  street=" + street + ""
                + "  city="+ city + ""
                + "  country=" + country + "]";
    }

}
